// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#include <pollux/vector/vector_encoding.h>

#include <stdexcept>

#include <fmt/core.h>
#include <melon/container/f14_map.h>

namespace kumo::pollux::VectorEncoding {
    Simple map_name_to_simple(const std::string &name) {
        static melon::F14FastMap<std::string, Simple> vecNameMap{
            {"BIASED", Simple::BIASED},
            {"CONSTANT", Simple::CONSTANT},
            {"DICTIONARY", Simple::DICTIONARY},
            {"FLAT", Simple::FLAT},
            {"SEQUENCE", Simple::SEQUENCE},
            {"ROW", Simple::ROW},
            {"MAP", Simple::MAP},
            {"ARRAY", Simple::ARRAY}
        };

        if (vecNameMap.find(name) == vecNameMap.end()) {
            throw std::invalid_argument(
                fmt::format("Specified vector encoding is not found : {}", name));
        }
        return vecNameMap[name];
    }
} // namespace kumo::pollux::VectorEncoding
